﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;

using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;

using System.Windows.Forms;



namespace HotelManager
{
    public partial class frmHome : Form
    {
        public bool updata = false;

        frmMainDatphongleft _frmDatPhongLeft = new frmMainDatphongleft();
        frmLoaiDichVu _frmLoaiDichVu = new frmLoaiDichVu();
        frmLoaiPhong _frmLoaiPhong = new frmLoaiPhong();
        frmMaindatphong _frmMainDatPhong = new frmMaindatphong();
        frmMainDichVu _frmMainDichVu = new frmMainDichVu();
        frmMainDichVuleft _frmMainDichVuLeft = new frmMainDichVuleft();
        frmMainKhachhang _frmMainKhachHang = new frmMainKhachhang();
        frmMainKhachhangleft _frmMainKhachHangLeft = new frmMainKhachhangleft();
        frmMainLoaiphong _frmMainLoaiPhong = new frmMainLoaiphong();
        frmMainLoaiPhongfleft _frmMainLoaiPhongLef = new frmMainLoaiPhongfleft();
        frmMainQLNhanVien _frmMainQLNhanVien = new frmMainQLNhanVien();
        frmMainQlPhong _frmMainQLPhong = new frmMainQlPhong();
        frmMainQLphongleft _frmMainQLPhongLeft = new frmMainQLphongleft();
        frmMainTimkiem _frmMainTimKiem = new frmMainTimkiem();
        frmMaintimkiemleft _frmMainTimKiemLeft = new frmMaintimkiemleft();
        frmMainDatphongleft _frmMainDatPhongLeft = new frmMainDatphongleft();
        frmMainPermissionForm _frmMainPermissionForm = new frmMainPermissionForm();
       
        /*
         * Bởi vì tất cả các form đều được load trong form chính, nên muốn đóng form ta chỉ dùng thuộc tính
         * _frmTenForm.Hide();
         * 
         */


        public frmHome()
        {

            InitializeComponent();

            _frmDatPhongLeft.MdiParent = this;
            _frmMainDatPhong.MdiParent = this;
            _frmMainDichVuLeft.MdiParent = this;
            _frmMainKhachHangLeft.MdiParent = this;
            _frmMainLoaiPhongLef.MdiParent = this;
            _frmLoaiDichVu.MdiParent = this;
            _frmLoaiPhong.MdiParent = this;
            _frmMainDatPhong.MdiParent = this;
            _frmMainDichVu.MdiParent = this;
            _frmMainKhachHang.MdiParent = this;
            _frmMainLoaiPhong.MdiParent = this;
            _frmMainQLNhanVien.MdiParent = this;
            _frmMainQLPhong.MdiParent = this;
            _frmMainTimKiem.MdiParent = this;
            _frmMainTimKiemLeft.MdiParent = this;
            _frmMainQLPhongLeft.MdiParent = this;
            _frmMainDatPhongLeft.MdiParent = this;
            _frmMainPermissionForm.MdiParent = this;

            this.pnlLeft.Controls.Add(_frmDatPhongLeft);
            this.pnlLeft.Controls.Add(_frmMainDichVuLeft);
            this.pnlLeft.Controls.Add(_frmMainKhachHangLeft);
            this.pnlLeft.Controls.Add(_frmMainLoaiPhongLef);
            this.pnlLeft.Controls.Add(_frmMainTimKiemLeft);
            this.pnlLeft.Controls.Add(_frmMainQLPhongLeft);
            this.pnlLeft.Controls.Add(_frmMainDatPhongLeft);

            this.pnlRight.Controls.Add(_frmLoaiDichVu);
            this.pnlRight.Controls.Add(_frmLoaiPhong);
            this.pnlRight.Controls.Add(_frmMainDatPhong);
            this.pnlRight.Controls.Add(_frmMainDichVu);
            this.pnlRight.Controls.Add(_frmMainKhachHang);
            this.pnlRight.Controls.Add(_frmMainLoaiPhong);
            this.pnlRight.Controls.Add(_frmMainQLNhanVien);
            this.pnlRight.Controls.Add(_frmMainQLPhong);
            this.pnlRight.Controls.Add(_frmMainTimKiem);
            this.pnlRight.Controls.Add(_frmMainPermissionForm);

        }

    
        private void btnViewBooked_Click(object sender, EventArgs e)
        {
            CommonHelper.OpenForm(_frmMainDatPhongLeft);
            CommonHelper.CloseAllFormInPanel(FormCollectionLeft(_frmMainDatPhongLeft));

            CommonHelper.OpenForm(_frmMainDatPhong);
            CommonHelper.CloseAllFormInPanel(FormCollectionRight(_frmMainDatPhong));
           
        }

        private void btnSearchAvailableRoom_Click(object sender, EventArgs e)
        {
    
            CommonHelper.OpenForm(_frmMainQLPhongLeft);
            CommonHelper.CloseAllFormInPanel(FormCollectionLeft(_frmMainQLPhongLeft));

            CommonHelper.OpenForm(_frmMainTimKiem);
            CommonHelper.CloseAllFormInPanel(FormCollectionRight(_frmMainTimKiem));
           
         
        }

        private void btnManageListGuest_Click(object sender, EventArgs e)
        {
            CommonHelper.OpenForm(_frmMainKhachHangLeft);
            CommonHelper.CloseAllFormInPanel(FormCollectionLeft(_frmMainKhachHangLeft));

            CommonHelper.OpenForm(_frmMainKhachHang);
            CommonHelper.CloseAllFormInPanel(FormCollectionRight(_frmMainKhachHang));
           
        }

        private void btnManageTypeRoom_Click(object sender, EventArgs e)
        {
            CommonHelper.OpenForm(_frmMainLoaiPhongLef);
            CommonHelper.CloseAllFormInPanel(FormCollectionLeft(_frmMainLoaiPhongLef));

            CommonHelper.OpenForm(_frmMainLoaiPhong);
            CommonHelper.CloseAllFormInPanel(FormCollectionRight(_frmMainLoaiPhong));
        }

        private void btnManageRoom_Click(object sender, EventArgs e)
        {
            CommonHelper.OpenForm(_frmMainQLPhongLeft);
            CommonHelper.CloseAllFormInPanel(FormCollectionLeft(_frmMainQLPhongLeft));

            CommonHelper.OpenForm(_frmMainQLPhong);
            CommonHelper.CloseAllFormInPanel(FormCollectionRight(_frmMainQLPhong));
        }

        private void btnServices_Click(object sender, EventArgs e)
        {
            CommonHelper.OpenForm(_frmMainDichVuLeft);
            CommonHelper.CloseAllFormInPanel(FormCollectionLeft(_frmMainDichVuLeft));

            CommonHelper.OpenForm(_frmMainDichVu);
            CommonHelper.CloseAllFormInPanel(FormCollectionRight(_frmMainDichVu));
        }

  


        private void btnReportTypeRoom_Click(object sender, EventArgs e)
        {

        }

        private void btnReportMonth_Click(object sender, EventArgs e)
        {

        }

        private void btnReportYear_Click(object sender, EventArgs e)
        {

        }

        private void frmHome_Load(object sender, EventArgs e)
        {
            _frmDatPhongLeft.Show();
            _frmMainDatPhong.Show();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Bạn chắc chắn muốn thoát","Nhắc nhở",MessageBoxButtons.OKCancel,MessageBoxIcon.Question)==DialogResult.OK)
            {
                Application.Exit();
            }
        }


        private List<Form> FormCollectionLeft(Form frRemove)
        {
            List<Form> clForm = new List<Form>();

            clForm.Add(_frmMainTimKiemLeft);
            clForm.Add(_frmMainQLPhongLeft);
            clForm.Add(_frmMainKhachHangLeft);
            clForm.Add(_frmMainDichVuLeft);
            clForm.Add(_frmDatPhongLeft);
            clForm.Add(_frmMainLoaiPhongLef);
            clForm.Add(_frmMainDatPhongLeft);

            clForm.Remove(frRemove);

            return clForm;
        }

        private List<Form> FormCollectionRight(Form frRemove)
        {
            List<Form> clForm = new List<Form>();

            clForm.Add(_frmMainLoaiPhong);
            clForm.Add(_frmLoaiDichVu);
            clForm.Add(_frmMainDatPhong);
            clForm.Add(_frmMainDichVu);
            clForm.Add(_frmDatPhongLeft);
            clForm.Add(_frmMainKhachHang);
            clForm.Add(_frmMainQLNhanVien);
            clForm.Add(_frmMainQLPhong);
            clForm.Add(_frmMainTimKiem);
            clForm.Add(_frmMainPermissionForm);
            clForm.Remove(frRemove);

            return clForm;
        }

        private void btnManageMember_Click(object sender, EventArgs e)
        {
            CommonHelper.OpenForm(_frmMainQLNhanVien);
            CommonHelper.CloseAllFormInPanel(FormCollectionRight(_frmMainQLNhanVien));
            
        }

        private void btnPermision_Click(object sender, EventArgs e)
        {
            CommonHelper.OpenForm(_frmMainPermissionForm);
            CommonHelper.CloseAllFormInPanel(FormCollectionRight(_frmMainPermissionForm));
        }

        private void btnQLChucVu_Click(object sender, EventArgs e)
        {
            frmAddNgheNghiep frm = new frmAddNgheNghiep();
            frm.ShowDialog();
            if (CommonHelper.Updata)
            {
                _frmMainPermissionForm.LoadChucVu();
                _frmMainPermissionForm.LoadUserAndRole();
               
            }
            CommonHelper.Updata = false;

           
        }

    





   

       
     

       
    }
}
